home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / DOS.SWG / 0065_File Attribute (BASM).pas < prev    next >
Pascal/Delphi Source File  |  1994-08-24  |  2KB  |  53 lines

  1. {
  2.  EH> I am looking for a way to determine a filehandles' attributes, like is
  3.  EH> possible in OS/2.
  4.  
  5.  EH> The attributes I like to query (and maybe set), are the standard-file
  6.  EH> attribs. Still I cannot find a way to get to them except with the
  7.  EH> filename, and a dos interrupt. What I am looking for is a dos interrupt
  8.  EH> that does exactly the same, but uses a filehandle instead of a filename.
  9.  
  10. No no no, file attributes can be returned/set only via DOS function 43h that
  11. assumes DS:DX point to a ASCIIZ file name. :(
  12.  
  13.   { File attributes (combine these when setting) }
  14.  
  15.   faNormal         = $0000;
  16.   faReadOnly       = $0001;
  17.   faHidden         = $0002;
  18.   faSysFile        = $0004;
  19.   faVolumeID       = $0008;
  20.   faDirectory      = $0010;
  21.   faArchive        = $0020;
  22.   faAnyFile        = $003F;
  23.  
  24. Function GetFileAttr(FileName : PChar) : integer; assembler;
  25. { Retrieves the attribute of a given file. The result is returned by DosError }
  26. Asm
  27.   MOV DosError,0
  28.   PUSH DS
  29.   LDS DX,FileName
  30.   MOV AX,4300h
  31.   INT 21h
  32.   POP DS
  33.   JNC @@noerror
  34.   MOV DosError,AX { save error code in DOS global variable }
  35. @@noerror:
  36.   MOV AX,CX
  37. End; { GetFileAttr }
  38.  
  39. Procedure SetFileAttr(FileName : PChar; Attr : word); assembler;
  40. { Sets the new attribute to a given file. The result is returned by DosError }
  41. Asm
  42.   MOV DosError,0
  43.   PUSH DS
  44.   LDS DX,FileName
  45.   MOV CX,Attr
  46.   MOV AX,4301h
  47.   INT 21h
  48.   POP DS
  49.   JC  @@noerror
  50.   MOV DosError,AX
  51. @@noerror:
  52. End; { SetFileAttr }
  53.